package edu.gatech.stolen.tea.unittest;
import static org.junit.Assert.*;

import java.util.ArrayList;

import org.junit.Before;
import org.junit.Test;

import edu.gatech.stolen.tea.*;
/**
 * A JUnite test for the filter class
 * @author Leshi
 *
 */
public class FilterTest {
	private Filter filter;
	private ItemEditor editor;
	private Accounts accounts;
	@Before
	public void setUp(){
		accounts =new Accounts();
		filter= new Filter();
		editor = new ItemEditor();
		User a = new User("a");
		editor.addNewUser(a);
		editor.setCurrentUser(a);
		ToDoItem i1=new ToDoItem();
		i1.setName("item1");
		i1.setCategory("School");
		i1.setDueDate("01/01/2011 11:11 PM");
		i1.setStatus(true);
		ToDoItem i2= new ToDoItem();
		i2.setName("item2");
		i2.setCategory("Personal");
		i2.setDueDate("02/02/2012 12:12 PM");
		i2.setStatus(false);
		editor.addItem(i1);
		editor.addItem(i2);
		
	}
	
	@Test
	public void testByCategory(){
		ArrayList<String> catList = Filter.byCategory("School",accounts.itemEditor);
		assertEquals("did not filter school category correctly", "item1", catList.get(0));
		catList=Filter.byCategory("Personal",accounts.itemEditor);
		assertEquals("did not filter school category correctly", "item2", catList.get(0));
		ToDoItem i3 = new ToDoItem();
		i3.setName("item3");
		i3.setCategory("Personal");
		editor.addItem(i3);
		catList=Filter.byCategory("Personal",accounts.itemEditor);
		assertEquals("did not filter school category correctly after adding an item", "item3", catList.get(1));

	}
}
